#!/usr/bin/env python
# -*- coding:utf-8 -*-

from flask_restful import Api

from . import article_blueprint
from api_1_0.articleResource.articleResource import ArticleResource
from api_1_0.articleResource.articleOtherResource import ArticleOtherResource

api = Api(article_blueprint)

api.add_resource(ArticleResource, '/<article_id>', '', endpoint='Article')


@article_blueprint.route('/update/<article_id>', methods=['PUT'], endpoint='ArticleUpdate')
def update(article_id):
    return ArticleOtherResource.sensitive_update(article_id)

# 用户上传文章
@article_blueprint.route('/add_article', methods=['POST'],endpoint='ArticleAdd')
def add_article():
    return ArticleOtherResource.add_article()

# 获取已审核的文章
@article_blueprint.route('/get_approved_articles', methods=['GET'],endpoint='ArticleGetApproved')
def get_approved_articles():
    return ArticleOtherResource.get_approved_articles()

# 获取未审核的文章
@article_blueprint.route('/get_disapproved_articles', methods=['GET'],endpoint='ArticleGetDisapproved')
def get_disapproved_articles():
    return ArticleOtherResource.get_disapproved_articles()

# 管理员审核文章
@article_blueprint.route('/approve_article/<article_id>', methods=['PUT'],endpoint='ArticleApproved')
def approve_article(article_id):
    return ArticleOtherResource.approve_article(article_id)

# 管理员删除文章
@article_blueprint.route('/delete_article/<article_id>', methods=['PUT'],endpoint='ArticleDelete')
def delete_article(article_id):
    return ArticleOtherResource.delete_article(article_id)